-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: stub for framework provider, mux, frameworking resource and datasource for metal_ssh_key #406
Conversation
Thsi is a WIP. I wonder if there's a way not to have acceptance tests run on every commit. |
51065e9
to
47c48a3
Compare
I think we can skip test execution for draft PRs. As I understand it, defining all required types in https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target without
Thoughts on this @ctreatma ? |
I do have, from time to time, drafts where I want to run E2E tests. Perhaps a label (No E2E Testing) or the title (WIP or NOE2E) could signal this? |
you can still run it manually since that condition is only for |
Yeah, @ocobles I think your suggestion is good. We should go with the second approach, adding a condition to the job (either by updating the |
I'm now doing the migration of the provider, and I also want to move resources and datasources to subdirectories, e.g The framework provider needs to refer to owned resource [0], and if we have resource in subdir, it needs to import the subdir (see top of I run into issues with the fact that we have a lot of helper code straight in the I am not sure how to resolve it. The natural solution would be to move the config (and all the helpers that resources and Config are using) to We need to break the cycle provider@equinix -> resource@equinix/metal_ssh_key/ -> config_struct,helpers@equinix It could be done without breaking things, if we copy all the necessary code to I think the helpers and config must be moved to a subdir eventually if we want to have resource code in subdirs. Or is there another solution in Go that I can't see? My suggestion is to move the helpers and config first, and continue with migration later. Also, it's important to do the move of the config and helpers properly, so that really all the functionality (and its dependencies) that resources need goes to a subdir. It should be done somehow aware of the framework provider and resources in subdir. Along with the move to I need your feedback @ctreatma @displague . Thanks for reading this. |
@t0mk have a look at #142. I was fairly far along in the refactoring of directories . The cyclical imports I was running into (and had yet to resolve) were in test mode. I wanted to keep equinix/ for the public Provider (name?) object so that other projects that import Terraform Go providers could do so. I moved all resources and "helpers" into internal/ with separate packages for each. |
@displague I see, you moved everything but provider.go provider_test.go and equinix_sweeper_test.go from Anyway, it looks like a way to go, and too bad you didn't manage to merge it last year. I don't think we need to move all resources to subdirs at this point, since we will migrate them to framework plugin ecventually. We just need one as a tracing bullet, to see that most of the helper code is separated from Give me green light on the code move and I will do a PR, restructure it in a reasonable way, and then we will discuss the paths and directory structure there, as that's not too relevant to the migration. |
@t0mk, yes, you can go ahead with the code move. If you're looking for a resource / datasource to use as a testbed, the |
@ctreatma , great! I will do so. I was thinking about metal_ssh_key myself. Actually we don't even have a datasource for the user key. |
My PR got too big too fast. |
Are there any disadvantages to moving into subfolders by service one level above the split by resource? I mean, |
Currently, we have a datasource for |
in response to this #406 (comment) --------- Signed-off-by: ocobleseqx <[email protected]>
Hi @t0mk, there are a few things I found while migrating resources that need to be addressed here:
//resource.go
//config.go
|
more findings @t0mk :
|
90f2213
to
cf8930f
Compare
that go test error after my last commit is related to https://developer.hashicorp.com/terraform/plugin/testing/migrating#flag-redefined-panic I'm going to open a different PR to fix the code before continuing with the work here. So basically we need to replace any resource.StateChangeConf references with helper/retry package |
…#524) Previous step to migrate testing functionality from github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource to github.com/hashicorp/terraform-plugin-testing/v2/helper/resource required to add e2e tests to migrate from SDKv2 to Framework #406 (comment) Almost all resource.StateChangeConf references had already been previously migrated to retry.StateChangeConf
72326a1
to
62e808e
Compare
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: ocobleseqx <[email protected]>
62e808e
to
fe8982f
Compare
@ctreatma definitely #551 worked as expected, I don't see that error anymore. Here's is the specific tests for both migrated resources https://github.com/equinix/terraform-provider-equinix/actions/runs/7744881780/job/21119662842#step:6:4306 https://github.com/equinix/terraform-provider-equinix/actions/runs/7744881780/job/21119662842#step:6:4405 |
examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example
Outdated
Show resolved
Hide resolved
…ted PR Signed-off-by: ocobleseqx <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I see all of the SSH key tests passing in CI (including the new upgrade test).
This PR is a first step towards migration from TF SDKv2 to the plugin Framework. It's along way, and Hashicorp documents it at [0].
We want to have both types of providers exist in the repo until we can totally migrate to framework. We need to use "muxing" [1].
I base this on the continuous migration of the Linode TF provider [2]. [3] is a first PR where they introduced the framework provider and migrated
token
resource to the framework format.For our case, I selected
metal_ssh_key
resource and datasource to migrate here, because those are simple resource types.[0] https://developer.hashicorp.com/terraform/plugin/framework/migrating
[1] https://developer.hashicorp.com/terraform/plugin/framework/migrating/mux
[2] https://github.com/linode/terraform-provider-linode
[3] linode/terraform-provider-linode#791
Towards #365